---
title: Adding items
category: demos
layout: default
has_modernizr: true
---




<div id="copy">
  <p>After adding items to a Masonry-ed container, you can properly lay them out using methods.   <code>appended</code> will layout new items to the end of the layout.  <code>reload</code> will layout all the item elements in the container, which is useful for prepending or inserting.</p>
</div>

<p>
  <button id="prepend">Prepend new items</button>
  <button id="append">Append new items</button>
</p>

<div id="container" class="transitions-enabled clearfix">

  <div class="box col2">
    <p>Sit amet mi ullamcorper vehicula</p>
  </div>

  <div class="box col1">
    <p>Phasellus pede arcu, dapibus eu, fermentum et, dapibus sed, urna.</p>
  </div>

  <div class="box col2">
    <p>Ut condimentum mi vel tellus. Suspendisse laoreet. Fusce ut est sed dolor gravida convallis. Morbi vitae ante. Vivamus ultrices luctus nunc. Suspendisse et dolor. Etiam dignissim. Proin malesuada adipiscing lacus. Donec metus. Curabitur gravida.</p>
    <p>Phasellus pede arcu, dapibus eu, fermentum et, dapibus sed, urna.</p>
  </div>

  <div class="box col2">
    <p>Vestibulum volutpat, lacus a ultrices sagittis,</p>
    <p>Fusce accumsan mollis eros. Pellentesque a diam sit amet mi ullamcorper vehicula  </p>
  </div>

  <div class="box col2">
    <p>Sit amet mi ullamcorper vehicula</p>
  </div>

  <div class="box col1">
    <p>Morbi purus libero</p>
  </div>

  <div class="box col1">
    <p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Donec odio. Quisque volutpat mattis eros. Nullam malesuada erat ut turpis. Suspendisse urna nibh, viverra non, semper suscipit, posuere a, pede.</p>
  </div>

  <div class="box col3">
    <p>Donec nec justo eget felis facilisis fermentum. Aliquam porttitor mauris sit amet orci. Aenean dignissim pellentesque felis.</p>
    <p>Vestibulum volutpat, lacus a ultrices sagittis,</p>
    <ul>
      <li>Lacus a ultrices sagittis</li>
      <li>Democratis</li>
    </ul>
  </div>


</div> <!-- #container -->

<script src="../{{ site.jquery_js }}"></script>
<script src="../{{ site.masonry_js }}"></script>
<script src="../js/box-maker.js"></script>
<script>
  $(function(){
    
    var $container = $('#container');
    
    $container.masonry({
      itemSelector: '.box',
      columnWidth: 100,
      isAnimated: !Modernizr.csstransitions
    });
    
    $('#prepend').click(function(){
      var $boxes = $( boxMaker.makeBoxes() );
      $container.prepend( $boxes ).masonry( 'reload' );
    });
    
    $('#append').click(function(){
      var $boxes = $( boxMaker.makeBoxes() );
      $container.append( $boxes ).masonry( 'appended', $boxes );
    });
    
  });
</script>